package de.koller.aframe.gl;

import de.koller.oceanFramework.gl.util.FrameTexture;
import org.lwjgl.opengl.GL11;

public class AFrame {

	private final int width, height;
	
	public FrameTexture frame;

	public AFrame( int width, int height ) {
		this.width = width;
		this.height = height;
	}

	
	public void setUp() {
		frame = FrameTexture.generate( width, height );
	}

	public void bind() {
		frame.bindFBOWithoutClear();
		frame.clearFBO( 1, 0, 0, 0 );
	}
	
	public void unbind() {
		frame.unbindFBO();
	}
	
	public void bindTexture() {
		frame.bindTexture();
	}

	public void renderScreen() {
		frame.bindTexture();
		GL11.glBegin( GL11.GL_QUADS );
			GL11.glTexCoord2f( 0, 1 );
			GL11.glVertex3f( 0, 0, 0 );
			
			GL11.glTexCoord2f( 0, 0 );
			GL11.glVertex3f( 0, height, 0 );
			
			GL11.glTexCoord2f( 1, 0 );
			GL11.glVertex3f( width, height, 0 );
			
			GL11.glTexCoord2f( 1, 1 );
			GL11.glVertex3f( width, 0, 0 );
		GL11.glEnd();
	}
	
}
